# Importing Data
IRAN<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "T1:T229")

# Checking the Imported Data
View(IRAN)
# Creating Time Series Data
IRAN_ts <- ts(IRAN, start=c(1998,1), end=c(2013,04), frequency=12)
# Viewing and Checking the Created Time Series Data
IRAN_ts
sum(is.na(IRAN_ts))
library(forecast)
IRAN_ts <- tsclean(IRAN_ts)
IRAN_ts

# Identification: Plotting the Time Series Data
plot(IRAN_ts)

# Estimating the appropriate model
IRAN_ts_model <- auto.arima(IRAN_ts)
IRAN_ts_model

# Forecasting
options(max.print=1000000)
IRAN_ts_forecast <- forecast (IRAN_ts_model, level=c(95), h=332)
plot(IRAN_ts_forecast)
IRAN_ts_forecast             

# Exporting
write.table(IRAN_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/IRAN_TSA.csv", sep=",")
